/*
 * Copyright (C) 2013 Fabiano Tarlao
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package org.easybenchmark.client;

import org.easybenchmark.client.arbiter.ResultManager;
import org.easybenchmark.client.benchmarks.Benchmark;
import org.easybenchmark.client.benchmarks.CollectionSortBenchmark;
import org.easybenchmark.client.benchmarks.FFTBenchmark;
import org.easybenchmark.client.benchmarks.RegExBenchmark;
import org.easybenchmark.client.benchmarks.SieveBenchmark;
import org.easybenchmark.client.benchmarks.StringCrunchBenchmark;

/**
 *
 * @author fab
 */
public class BenchmarkPool {

    ResultManager resultManager;
    public BenchmarkPool(String userAgentOrJavaVMversion) {
        resultManager = new ResultManager(userAgentOrJavaVMversion);
    }
    
    
    //confguration
    
    public ResultManager executeAllBenchmarks(){
         int fftArraySize = 4096; //bytes
                int fftIterations = 1000;
                int collectionSize = 1000; //number of Objects/Integers
                int collectionIterations = 1000;
                int sieveNumericRange = 1000; //size of the numeric search range  [0,sieveNUmericRange]
                int sieveIterations = 5000;
                int stringSize = 400;
                int stringItrerations = 200000;
                int regexTextSize = 200;
                int regexIterations = 400000;

                //HighMem benchmarks
                int fftArraySizeHM = 4096*8;
                int fftIterationsHM = 100;
                int collectionSizeHM = 100000;
                int collectionIterationsHM = 2;
                int sieveNumericRangeHM = 30000;
                int sieveIterationsHM = 200;
                int stringSizeHM=200000;
                int stringItrerationsHM = 10;
                int regexTextSizeHM = 20000;
                int regexIterationsHM = 50000;


               
               
               RegExBenchmark regexBenchmark1 = new RegExBenchmark(regexTextSize);
               regexBenchmark1.start(regexIterations);
               resultManager.add(regexBenchmark1);
               this.statusMessages+="\n outcome of "+regexBenchmark1.getBenchmarkName()+" is: "+regexBenchmark1.getDestString();
               
               Benchmark fftBenchmark = new FFTBenchmark(fftArraySize);
               fftBenchmark.start(fftIterations);

               resultManager.add(fftBenchmark);
               Benchmark collectionBench = new CollectionSortBenchmark(collectionSize);
               collectionBench.start(collectionIterations);
               resultManager.add(collectionBench);
               Benchmark sieveBench = new SieveBenchmark(sieveNumericRange);
               sieveBench.start(sieveIterations);
               resultManager.add(sieveBench);
               Benchmark stringBenchmark = new StringCrunchBenchmark(stringSize);
               stringBenchmark.start(stringItrerations);
               resultManager.add(stringBenchmark);
               
               //memory load high
               RegExBenchmark regexBenchmark2 = new RegExBenchmark(regexTextSizeHM);
               regexBenchmark2.start(regexIterationsHM);
               resultManager.add(regexBenchmark2);
               this.statusMessages+="\n outcome of "+regexBenchmark1.getBenchmarkName()+" is: "+regexBenchmark2.getDestString();
               
               
               fftBenchmark = new FFTBenchmark(fftArraySizeHM);
               fftBenchmark.start(fftIterationsHM);
               resultManager.add(fftBenchmark);
               collectionBench = new CollectionSortBenchmark(collectionSizeHM);
               collectionBench.start(collectionIterationsHM);
               resultManager.add(collectionBench);
               sieveBench = new SieveBenchmark(sieveNumericRangeHM);
               sieveBench.start(sieveIterationsHM);
               resultManager.add(sieveBench);
               stringBenchmark = new StringCrunchBenchmark(stringSizeHM);
               stringBenchmark.start(stringItrerationsHM);
               resultManager.add(stringBenchmark);
               return resultManager;
    }
    
    
    private String statusMessages = "";
    
    /**
     * return special status messages, this may contains particular benchmark outcomes
     * @return
     */
    public String getStatusMessages(){
        return statusMessages;
    }
}
